//
// Created by wangwanlong on 2024/12/11.
//
#include "graph.h"
#include "utils/macros.h"
#include "io/graph_io.h"

//算例名字 输出目录
int main(int argc, char **argv){
  if(argc != 3){
    std::cout<<"params error!";
    exit(-1);
  }
  std::string file = argv[1];
  int mqi_no = atoi(argv[2]);

  std::cout<<"file:"<<file<<std::endl;
  std::cout<<"mqi no:"<<mqi_no<<std::endl;
  init::Graph g;
  std::string graph_file = ".." + PATH_SEPARATOR_STR + "instance" + PATH_SEPARATOR_STR + file + ".graph";
  std::string seed_file = ".." + PATH_SEPARATOR_STR + "MQI_BKV" + PATH_SEPARATOR_STR + file + PATH_SEPARATOR_STR + file + "_result_" + std::to_string(mqi_no) + ".smat";
  double cond = g.calConductance(graph_file,seed_file);

  //保存到文件: runtime/initResult
  std::string output_path = "initResult";
  mcgpp::io::createDirectories(output_path);

  std::cout<<"output path:"<<output_path<<std::endl;
  std::ofstream op(output_path + PATH_SEPARATOR_STR + file + ".7_20",std::ios_base::app);//追加写入
  if(op) {
    //算例 mqi_no conductance
    std::cout << file << "," << mqi_no << "," << std::fixed << std::setprecision(10) << cond << std::endl;
    op << file << "," << mqi_no << "," << std::fixed << std::setprecision(10) << cond << std::endl;
    op.close();
  }
  else{
    std::cout<<"fail create file!";
  }

}
